Imports System.Windows.Forms

Public Class dlgReport

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click


        If rbToday.Checked Then
            MessageBox.Show("")
            Report.StartDate = New Date(Today.Year, Today.Month, Today.Day, 0, 0, 0)
            Report.EndDate = New Date(Today.Year, Today.Month, Today.Day, 23, 59, 59)
        End If
        If rbQuarter.Checked Then
            Report.StartDate = db.getvalue("Select qStartDate from Quarters where QuarterID = '" & cbQuarter.SelectedItem.item(0) & "'", "qStartDate")
            Report.EndDate = db.getvalue("Select qEndDate from Quarters where QuarterID = '" & cbQuarter.SelectedItem.item(0) & "'", "qEndDate")
        End If
        If rbManual.Checked Then
            Report.StartDate = New Date(dtpFrom.Value.Year, dtpFrom.Value.Month, dtpFrom.Value.Day, 0, 0, 0)
            Report.EndDate = New Date(dtpTo.Value.Year, dtpTo.Value.Month, dtpTo.Value.Day, 23, 59, 59)
        End If
        Report.couponlimit = nupCoupon.Value
        'Me.DialogResult = System.Windows.Forms.DialogResult.OK
        'Me.Close()
        Report.RType = "TOTAL"
        Report.ShowDialog()

    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub dlgReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dtpFrom.Value = Today.Date
        dtpTo.Value = Today.Date
        cbQuarter.DataSource = db.getvalue("Select * from Quarters").Tables(0)
        cbQuarter.DisplayMember = "QuarterID"
        cbQuarter.ValueMember = "QuarterID"
    End Sub


    Private Sub cbQuarter_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbQuarter.SelectedIndexChanged
        lblQuarter.Text = "From '" & CType(cbQuarter.SelectedItem.item("qStartdate"), Date).ToShortDateString & "' to '" & CType(cbQuarter.SelectedItem.item("qEnddate"), Date).ToShortDateString & "'"
    End Sub
End Class
